﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static 天离安卓权限维持系统.Api.ListConfigApi;
using static 天离安卓权限维持系统.Form1;

namespace 天离安卓权限维持系统.Services
{
    public class Json_Services
    {
        public static ListenerList ReadJson(string filePath)
        {
            if (File.Exists(filePath))
            {
                string jsonData = File.ReadAllText(filePath);
                return JsonConvert.DeserializeObject<ListenerList>(jsonData);
            }
            return null;
        }

        public static void WriteJson(string filePath, ListenerList listeners)
        {
            string jsonData = JsonConvert.SerializeObject(listeners, Formatting.Indented);
            File.WriteAllText(filePath, jsonData);
        }
    }
}
